import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'
import fileText from './modules/fileText'
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [createPersistedState()],
  modules: {
    common,
    user,
    fileText
  },
  mutations: {
    // 重置vuex本地储存状态
    resetStore (state) {
      let old = cloneDeep(JSON.parse(sessionStorage.getItem("storeState")));
      console.log("tes1111t\n");

      console.log(old);
      Object.keys(state).forEach((key) => {
        state[key] = old[key]
      })
    }
  },
  strict: process.env.NODE_ENV !== 'production'
})
